import { axios } from '@/utils/request'

const api = {
  // 工种管理
  workType: '/mes/workType',
  workTypeList: '/mes/workType/list',
  workTypeAdd: '/mes/workType/add',
  workTypeEdit: '/mes/workType/edit',
  workTypeDelete: '/mes/workType/delete',
  workTypeBatchDelete: '/mes/workType/deleteBatch',
  workTypeExport: '/mes/workType/exportXls',
  workTypeImport: '/mes/workType/importExcel',
  workTypeCheckCode: '/mes/workType/checkWorkTypeCode',
  
  // 员工工种分配
  employeeWorkType: '/mes/employeeWorkType',
  employeeWorkTypeList: '/mes/employeeWorkType/list',
  employeeWorkTypeAdd: '/mes/employeeWorkType/add',
  employeeWorkTypeEdit: '/mes/employeeWorkType/edit',
  employeeWorkTypeDelete: '/mes/employeeWorkType/delete',
  employeeWorkTypeBatchDelete: '/mes/employeeWorkType/deleteBatch',
  employeeWorkTypeExport: '/mes/employeeWorkType/exportXls',
  employeeWorkTypeAssign: '/mes/employeeWorkType/assign',
  employeeWorkTypeByEmployee: '/mes/employeeWorkType/queryByEmployee'
}

// 工种管理API
export function getWorkTypeList(parameter) {
  return axios({
    url: api.workTypeList,
    method: 'get',
    params: parameter
  })
}

export function addWorkType(parameter) {
  return axios({
    url: api.workTypeAdd,
    method: 'post',
    data: parameter
  })
}

export function editWorkType(parameter) {
  return axios({
    url: api.workTypeEdit,
    method: 'put',
    data: parameter
  })
}

export function deleteWorkType(parameter) {
  return axios({
    url: api.workTypeDelete,
    method: 'delete',
    params: parameter
  })
}

export function batchDeleteWorkType(parameter) {
  return axios({
    url: api.workTypeBatchDelete,
    method: 'delete',
    data: parameter
  })
}

export function exportWorkType(parameter) {
  return axios({
    url: api.workTypeExport,
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}

export function checkWorkTypeCode(parameter) {
  return axios({
    url: api.workTypeCheckCode,
    method: 'get',
    params: parameter
  })
}

// 员工工种分配API
export function getEmployeeWorkTypeList(parameter) {
  return axios({
    url: api.employeeWorkTypeList,
    method: 'get',
    params: parameter
  })
}

export function addEmployeeWorkType(parameter) {
  return axios({
    url: api.employeeWorkTypeAdd,
    method: 'post',
    data: parameter
  })
}

export function editEmployeeWorkType(parameter) {
  return axios({
    url: api.employeeWorkTypeEdit,
    method: 'put',
    data: parameter
  })
}

export function deleteEmployeeWorkType(parameter) {
  return axios({
    url: api.employeeWorkTypeDelete,
    method: 'delete',
    params: parameter
  })
}

export function batchDeleteEmployeeWorkType(parameter) {
  return axios({
    url: api.employeeWorkTypeBatchDelete,
    method: 'delete',
    data: parameter
  })
}

export function exportEmployeeWorkType(parameter) {
  return axios({
    url: api.employeeWorkTypeExport,
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}

export function assignEmployeeWorkType(parameter) {
  return axios({
    url: api.employeeWorkTypeAssign,
    method: 'post',
    data: parameter
  })
}

export function getEmployeeWorkTypeByEmployee(parameter) {
  return axios({
    url: api.employeeWorkTypeByEmployee,
    method: 'get',
    params: parameter
  })
}
